import { createRouter, createWebHistory } from "vue-router";
import { loginRoute } from "./constants";

// 获取modules文件下的异步全量路由
const modules = import.meta.glob("./modules/*.ts", {
  eager: true,
  import: "default",
});
// 获取值数组，因为要一维，所以遍历展开再合并
export const asyncModulesList: any = [];
Object.values(modules).forEach((item: any) => {
  asyncModulesList.push(...item);
});

// 路由器
const router = createRouter({
  history: createWebHistory(),
  // routes: [loginRoute, emptyRoute, ...asyncModulesList],
  routes: [loginRoute],
});

export default router;
